/* sfacct1a.i - OPERATIONS ACCOUNTING REPORT INCLUDE FILE                  */
/* Copyright 1986-2011 QAD Inc., Santa Barbara, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Id:: sfacct1a.i 2366 2010-11-10 01:47:19Z zzh                          $: */
/*V8:ConvertMode=Report                                                       */
/* Revision: 1.3       BY: Vandna Rohira          DATE: 08/07/01  ECO: *M1DM* */
/* Revision: 1.5       BY: Paul Donnelly (SB)     DATE: 06/28/03  ECO: *Q00L* */
/* Revision: 1.6       BY: Annapurna V            DATE: 11/22/04  ECO: *P2VY* */
/* Revision: 1.7       BY: Dinesh Dubey           DATE: 03/04/07  ECO: *R0C6* */
/* $Revision: 1.9 $    BY: Katie Hilbert          DATE: 04/24/08  ECO: *R0RX* */
/*-Revision end---------------------------------------------------------------*/

/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/*-------------------------------------------------------------------------*/
/* DESCRIPTION: THIS PROGRAM CONTAINS THE PROCESSING LOGIC FOR CREATING    */
/*              RECORDS IN THE TEMP-TABLE tt_gltw_wkfl WHEN gl_yn IS SET   */
/*              TO YES AND PRINTING THE REPORT WHEN tr_yn IS SET TO YES    */
/*                                                                         */
/*-------------------------------------------------------------------------*/

if gl_yn
then do:
   /* CREATING RECORDS IN tt_gltw_wkfl */
   {us/bbi/gprun.i ""sfacct02.p""
      "(buffer opgl_det,
        buffer op_hist)"}
end.   /* IF GL_YN   */

if tr_yn
then do:

   assign
      desc1 = ""
      desc2 = "".

   for first pt_mstr
      where pt_domain = global_domain 
      and pt_part = op_part
   no-lock:
      desc1 = pt_desc1.
   end. /* FOR FIRST pt_mstr */
 
  mfgtype = "".
   for first wo_mstr no-lock 
    where wo_mstr.wo_domain = global_domain
      and wo_lot            = op_wo_lot,
    first lngd_det no-lock where lngd_dataset = c-lngd-dataset
      and lngd_field   = "orderType"
      and lngd_lang    = global_user_lang
      and lngd_key1    = wo_mfg_type:
      assign
         mfgtype = lngd_key2.
   end.

   if page-size - line-counter < 4
   then
      page.

   if opgl_type matches "LBR-.000"
   then
      desc2 = opgl_type + ": " + getTermLabel("LABOR",16).
   else
   if opgl_type matches "BDN-.000"
   then
      desc2 = opgl_type + ": " + getTermLabel("BURDEN",16).
   else
   if opgl_type matches "SUB-.000"
   then
      desc2 = opgl_type + ": " + getTermLabel("SUBCONTRACT",16).
   else
   if opgl_type matches "LBR-.001"
   then
      desc2 = opgl_type + ": " +
      getTermLabel("LABOR_RATE_VARIANCE",16).
   else
   if opgl_type matches "BDN-.001"
   then
      desc2 = opgl_type + ": " +
      getTermLabel("BURDEN_RATE_VARIANCE",16).
   else
   if opgl_type matches "SUB-.001"
   then
      desc2 = opgl_type + ": " +
      getTermLabel("SUB_RATE_VARIANCE",16).
   else
   if opgl_type matches "LBR-.002"
   then
      desc2 = opgl_type + ": " +
      getTermLabel("LABOR_USAGE_VARIANCE",16).
   else
   if opgl_type matches "BDN-.002"
   then
      desc2 = opgl_type + ": " +
      getTermLabel("BURDEN_USAGE_VARIANCE",16).
   else
   if opgl_type matches "SUB-.002"
   then
      desc2 = opgl_type + ": " +
      getTermLabel("SUB_USAGE_VARIANCE",16).
   else
   if opgl_type begins "PR-"
   then
      desc2 = opgl_type + ": " +
      getTermLabel("PAYROLL_XFER_VARIANCE",16).
   else desc2 = opgl_type.

   if opgl_type matches "...-1000"
   then
      desc2 = desc2 + " " + getTermLabel("SETUP",5).
   if desc2 = ""
   then
      desc2 = op_type.

   if oldtrnbr <> op_trnbr
   then do:

      down 1 with frame b.
      display
         op_part   @ op_wo_nbr
         op_wo_lot @ oplot
         mfgtype @ typeglref
         '                ' + desc1 @ glrefid
         with frame b.

      oldtrnbr = op_trnbr.

   end. /* IF oldtrnbr <> op_trnbr */

   if l_optrnbr <> op_trnbr
   then do:

      down 1 with frame b.

      display
         op_date
         op_trnbr format ">>>>>>>9"
         op_wo_nbr @ opwonbr
         string(op_wo_op) @ oplot
         opgl_gl_ref  @ typeglref
         desc2
         opgl_dr_acct @ drcract
         opgl_dr_sub  @ subact
         opgl_dr_cc   @ ccdisp
         opgl_gl_amt
         with frame b.

      down 1 with frame b.

      display
         opgl_gl_ref + '  ' + desc2  @ glrefid
         opgl_cr_acct @ drcract
         opgl_cr_sub  @ subact
         opgl_cr_cc   @ ccdisp
         with frame b.

      l_optrnbr = op_trnbr.

   end. /* IF l_optrnbr <> op_trnbr */

   else do:

      down 1 with frame b.

      display
         opgl_gl_ref  @ typeglref
         desc2
         opgl_dr_acct @ drcract
         opgl_dr_sub  @ subact
         opgl_dr_cc   @ ccdisp
         opgl_gl_amt
         with frame b.

      down 1 with frame b.

      display
         opgl_gl_ref + '  ' + desc2  @ glrefid
         opgl_cr_acct @ drcract
         opgl_cr_sub  @ subact
         opgl_cr_cc   @ ccdisp
         with frame b.

   end. /* IF l_optrnbr = op_trnbr */

   {us/mf/mfrpchk.i &warn=false}
end. /* IF tr_yn */
